<?php $GLOBALS['script'][] = function() {?><script>
vue.methods.swapip = function () {
    var msg = "";
    msg += "如果您的公网IP被DDOS了又不想等待150分钟解封，\r\n";
    msg += "那么或许【更换公网IP】是最快的解决办法了。\r\n";
    msg += "您当前要操作的公网IP为：" + vue.data.choice_hostuser.vps_wanipv4 + "\r\n";
    msg += "您确定要【更换公网IP】吗？";
    if (confirm(msg)) {
        vue.data.form.action = 'swapip';
        vue.methods.submit_operate();
    }
};
vue.methods.admin = function () {
    vue.data.disabled++;
    const form = window.clone(vue.data.form);
    this.ApiPost('/panel/yun/nthost/admin.php', form).then(function (res) {
    }, function (res) {
        console.log('reject:', res);
    }).catch(function (reason) {
        console.log('catch:', reason);
    }).then(function () {
        vue.data.disabled--;
    });
};
vue.methods.admin_vnc = function () {
    vue.data.disabled++;
    const form = window.clone(vue.data.form);
    this.ApiPost('/panel/yun/nthost/vnc.php', form).then(function (res) {
        const ret = vue.data.api.vnc = res.data;
        const oParam = {};
        oParam.vncUrl = ret.vncUrl;
        oParam.instanceId = ret.instanceId;
        oParam.isWindows = ret.isWindows;
        oParam.password = ret.password;
        const aParam = [];
        for (var key in oParam) {
            aParam.push(key + '=' + oParam[key]);
        }
        window.open('https://g.alicdn.com/aliyun/ecs-console-vnc2/0.0.5/index.html?' + aParam.join('&'));
    }, function (res) {
        console.log('reject:', res);
    }).catch(function (reason) {
        console.log('catch:', reason);
    }).then(function () {
        vue.data.disabled--;
    });
};
vue.methods.admin_stop = function () {
    var msg = "";
    msg += "【停机保盘】最长可免费保留7天，超时后数据将被删除！\r\n";
    msg += "【停机保盘】处理大约需要10分钟，并自动生成账单。\r\n";
    msg += "【停机保盘】将导致原公网IP将丢失，重开需使用新的公网IP\r\n";
    msg += "【停机保盘】后如需重新开机，需先去手动支付未结算的账单\r\n";
    msg += "【停机保盘】后无法退回押金，您需要重新开机后销毁主机\r\n";
    msg += "当前要操作的主机公网IP为：" + vue.data.choice_hostuser.vps_wanipv4 + "\r\n";
    msg += "您确定要【停机保盘】吗？";
    if (confirm(msg)) {
        vue.data.form.action = 'stop';
        vue.methods.submit_operate();
    }
};
</script><?php }?>
<div class="box-body">
    <div class="box-body">
        <div class="box-footer col-sm-6 col-xs-12" v-if="choice_hostuser['host_type']==2">
            <button type="button" class="btn btn-info btn-block btn-flat" v-on:click="form.action='boot';admin();" :disabled="disabled>0">开机</button>
        </div>
        <div class="box-footer col-sm-3 col-xs-6" v-if="choice_hostuser['host_type']==2&&0">
            <button type="button" class="btn btn-info btn-block btn-flat" v-on:click="form.action='stop';admin();" :disabled="disabled>0">关机</button>
        </div>
        <div class="box-footer col-sm-6 col-xs-12" v-if="choice_hostuser['host_type']==2">
            <button type="button" class="btn btn-info btn-block btn-flat" v-on:click="admin_vnc" :disabled="disabled>0">远程VNC管理</button>
        </div>
        <div class="box-footer col-sm-6 col-xs-12">
            <button type="button" class="btn btn-warning btn-block btn-flat" v-if="choice_hostuser['host_type']==2" v-on:click="reboot" :disabled="disabled>0">强制重启</button>
            <button type="button" class="btn btn-warning btn-block btn-flat" v-else v-on:click="logoff" :disabled="disabled>0">停止计费</button>
        </div>
        <div class="box-footer col-sm-6 col-xs-12" v-if="choice_hostuser['host_type']==2">
            <button type="button" class="btn btn-warning btn-block btn-flat" v-on:click="admin_stop" :disabled="disabled>0">停机保盘</button>
        </div>
        <div class="box-footer col-sm-6 col-xs-12" v-if="choice_hostuser['host_type']==2">
            <button type="button" class="btn btn-warning btn-block btn-flat" v-on:click="swapip" :disabled="disabled>0">更换公网IP</button>
        </div>
        <div class="box-footer col-sm-6 col-xs-12">
            <button type="button" class="btn btn-info btn-block btn-flat" v-on:click="tabclick('setpwd')">重设密码</button>
        </div>
        <div class="box-footer col-sm-6 col-xs-12">
            <button type="button" class="btn btn-info btn-block btn-flat" v-on:click="tabclick('destroy')">销毁主机</button>
        </div>
        <div class="box-footer col-sm-6 col-xs-12">
            <button type="button" class="btn btn-default btn-block btn-flat" v-on:click="tabclick('info')">返回详情</button>
        </div>
    </div>
</div>
